package com.shaozi.nc.manage.rules;

import java.text.ParseException;

import org.quartz.CronExpression;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;

import com.shaozi.utils.common.BeanUtils;

public class WorkReportCompRules {
	@Value("${rule.report.write.default}")
	private String ruleReportWriteDefault;

	public WorkReportCompRules() {

	}

	public String buildDefaultWritePush(String compId) {
		String rule = BeanUtils.getConfig().getValue("");
		if (StringUtils.isEmpty(rule))
			rule = defaultWritePush(compId);
		return rule;
	}

	public String buildDefaultWriteTitle(String compId) {
		return "工作汇报提醒";
	}

	public String buildDefaultWriteContent(String compId) {
		return "%s 你好，现在已经%s分了，一天工作马上结束了，记得写今天的工作汇报!";
	}

	/**
	 * 每周一到周五六点触发
	 * 
	 * @param compId
	 * @return
	 */
	private String defaultWritePush(String compId) {
		return "0 0 18 ? * MON-FRI";
	}

	public static void main(String[] args) {
		WorkReportCompRules r = new WorkReportCompRules();
		try {
			CronExpression.validateExpression(r.defaultWritePush("100000000"));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
